<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>下单结算</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/main.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/shop.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/square/red.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>views/css/user.css" />
<script type="text/javascript"
	src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body>
	<form style="display: none;" id="dataform">
		<input type="text" value="${address.id}" name="address_id"
			id="addressid"> <input type="text" value="2" name="payType"
			id="payType"> <input type="text" value="${transportcost}"
			name="sendfee" id="sendfee"> <input type="text"
			value="${paymoney}" name="sumPrice" id="sumPrice">
	</form>
	<div class="mwrap">
		<!--订单编号b -->
		<!-- <div class="border_box" id="divOrderNo">
			<div class="h3_item box_con">
				<div class="useAccount">订单编号：0000000000001</div>
			</div>
		</div> -->
		<!--订单编号e -->
		<!--所购商品b -->
		<div class="border_box">
			<div class="goods-box">
				<ul id="ulProductInfo">
					<c:forEach items="${cars}" var="carinfo">
						<li><div class="goods-list">
								<div class="pic">
									<a href="#"><img
										src="<%=imagePath %>${carinfo.goods.image}"></a>
								</div>
								<div class="info">
									<div class="goods-name">
										<a href="#">${carinfo.goods.name}</a>
									</div>
									<div>
										<a class="goods-price word-color">￥${carinfo.product.price}</a>
										<span class="goods-amount">×${carinfo.count}</span>
									</div>
								</div>
							</div>
							<div class="clear"></div></li>
					</c:forEach>
				</ul>
			</div>
		</div>
		<!--所购商品e -->

		<!--金额b -->
		<div class="border_box" style="margin-top: -1px">
			<div class="h3_item box_con">
				<div class="useAccount" id="divTotalPriceInfo">
					快递费用:<span class="word-color">${transportcost}</span><label>元</label>&nbsp;&nbsp;&nbsp;订单总价(含运费):<span
						class="word-color">${paymoney}</span>元
				</div>
			</div>
		</div>
		<!--金额e -->

		<!--用户地址信息 -->
		<div class="mt10">
			<div class="border_box ">
				<div class="list-group-new" id="divOrderInfo">
					<ul>
						<c:choose>
							<c:when test="${!empty address}">
								<li onclick="OrderPayment.AddressSelect();"><label>收件人：</label><span>${address.name}</span><span
									class="pull-right">${address.phone}</span><br> <label>收货地址：</label><span>${address.address}</span></li>
							</c:when>
							<c:otherwise>
								<li id="btnAdd" class="address-row"
									onclick="OrderPayment.AddressSelect();"><a href="#">选择收货地址></a></li>
							</c:otherwise>
						</c:choose>
					</ul>
				</div>
			</div>
		</div>
		<!--支付方式 -->
		<div class="mt10">
			<div class="border_box ">
				<div class="list-group-new">
					<ul>	
						<li>					
							<label><input type="radio" name="pay" id="inlineRadio2" value="2" checked> 微支付</label>	
						</li>						
					</ul>
				</div>
			</div>
		</div>

	</div>
	<div class="buySection">
		<!-- <button type="button" id="btnSubmit" class="btn btn-block btn-color ">
		</button> -->
		<button type="button" onclick="pay()" class="btn btn-block btn-color ">确认支付
		</button>
	</div>
	<div id="divAddressSelect" style="display: none;">
		<!--地址列表 -->
		<ul class="address_list">
			<c:forEach items="${addressList}" var="address">
				<li class="address-row"
					onclick="OrderPayment.getAddress('${address.id}','${address.name}','${address.phone}','${address.province}${address.city}${address.county}${address.address}','${address.province}')"><div
						class="font-32">
						<b>${address.name}</b> <b>${address.phone}</b>
						<c:if test="${address.enable==1}">
							<label class="red">默认地址</label>
						</c:if>
					</div>
					<div class="color9">${address.province}${address.city}${address.county}${address.address}</div></li>
			</c:forEach>
		</ul>
		<ul>
			<li id="btnAdd" class="address-row "><a
				href="../mobile/createAddress"> 新增收货地址></a></li>
		</ul>
		<ul>
			<button type="button" class="btn btn-block"
				onclick="javascript:layer.closeAll();">返 回</button>
		</ul>
		<!--列表e -->
	</div>
	<!--添加地址b -->
	<%-- <div id="divAddressAdd" style="display: block;">
		<div class="edit_add">
			<form id="address_form" class="form-inline"
				action="<%=basePath%>mobile/address_insertOrUpdate">
				<ul style="padding-top: .6em;">
					<li style="margin-top: 0px;"><span class="left_tit"><span
							class="red pr5">*</span>收货人</span> <span class="right_text"> <input
							type="text" value="" class="form-control custName" id="custName"
							name="custName" placeholder="姓名" data-role="none">
					</span></li>
					<li><span class="left_tit"><span class="red pr5">*</span>手机号码</span>
						<span class="right_text"> <input type="text" value=""
							class="form-control mobile" id="mobile" name="mobile"
							placeholder="手机号码" data-role="none">
					</span></li>
					<!-- <li><span class="left_tit"><span class="red pr5">*</span>省份</span>
						<div class="right_text">
							<div class="right_select">
								<select class="form-control address_province_list"
									id="address_province_list" name="provinceid"
									onchange="OrderPayment.getCityList(this.value);">
									<option value="-1" style="color: #acacac">请选择省份...</option>
								</select> 
								<select class="form-control" id="cmbProvince" name="cmbProvince"></select>
								<span class="bg_span"></span>
							</div>
						</div></li>
					<li><span class="left_tit"><span class="red pr5">*</span>城市</span>
						<div class="right_text">
							<div class="right_select">
								<select class="form-control address_city_list"
									id="address_city_list" name="cityid"
									onchange="OrderPayment.getCountyList(this.value);">
									<option value="-1" style="color: #acacac">请选择城市...</option>
								</select>
								<select class="form-control" id="cmbCity" name="cmbCity"></select>
								<span class="bg_span"></span>
							</div>
						</div></li>
					<li><span class="left_tit">区县</span>
						<div class="right_text">
							<div class="right_select">
								<select class="form-control address_county_list"
									id="address_county_list" name="countyid">
									<option value="-1" style="color: #acacac">请选择区县...</option>
								</select>
								<select class="form-control" id="cmbArea" name="cmbArea"></select>
								<span class="bg_span"></span>
							</div>
						</div></li> -->
					<div data-toggle="distpicker">
						<div class="form-group">
							<label class="sr-only" for="province1">Province</label> <select
								class="form-control" id="province1"></select>
						</div>
						<div class="form-group">
							<label class="sr-only" for="city1">City</label> <select
								class="form-control" id="city1"></select>
						</div>
						<div class="form-group">
							<label class="sr-only" for="district1">District</label> <select
								class="form-control" id="district1"></select>
						</div>
					</div>
					<li><span class="left_tit"><span class="red pr5">*</span>详细地址</span>
						<span class="right_text"> <input type="text" value=""
							class="form-control address" id="address" name="address"
							placeholder="详细地址" data-role="none">
					</span></li>
					<!-- <li><span class="left_tit">邮政编码</span> <span
						class="right_text"> <input type="text" value=""
							class="form-control txtZipCode" id="txtZipCode" maxlength="6"
							name="txtZipCode" placeholder="邮政编码" data-role="none">
					</span></li> -->
				</ul>
				<div class="mcontainer mt15">
					<input type="submit" class="btn btn-primary btn-block" id="btnSave"
						value="确定" onclick="OrderPayment.SaveAddress(); return false;" />
				</div>
				<div class="mcontainer">
					<button type="button" class="btn btn-block"
						onclick="javascript:layer.closeAll();">返 回</button>
				</div>
			</form>
		</div>
	</div> --%>
	<!--添加地址e -->
	<!--弹层确定b -->
	<!-- <div class="refer-dialog" style="display: None">
		<div class="norms-content">
			<div class="body">
				<div class="hd clearfix">
					<div class="head-img left"></div>
					<div class="info">
						<p class="title"></p>
						<p class="f14 deep-orange price "></p>
					</div>
					<div class="close">
						<i class="fa fa-close"></i>
					</div>
				</div>
				<div class="norms-info mb10 ">
					<div class="norms-info">
						<div class="itemofamountspec"></div>
						<div class="item">
							<label class="color9"
								style="float: left; width: 30%; font-size: 16px;"> 付款方式：</label><span
								class="payType color9" style="float: right; font-size: 16px;"></span>
						</div>
						<div class="item">
							<label class="color9"
								style="float: left; width: 30%; font-size: 16px;"> 折扣优惠：</label><span
								class="payYouhui color9" style="float: right; font-size: 16px;"></span>
						</div>
						<div class="item">
							<label class="deep-gray"
								style="float: left; width: 30%; font-size: 17px;"> 需付款：</label><span
								class="goods_prices price word-color"
								style="float: right; font-size: 25px; vertical-align: top; margin-top: -1em;">¥0.00</span>
						</div>
					</div>
				</div>
				<div class="norms-info-footer">
					<input type="hidden" name="hidType" value="" id="Hidden1" />
					<button type="button" class="btn btn-block" id="btnConfirmBuy">
						确定付款</button>
				</div>
			</div>
		</div>
		<div class="bg"></div>
	</div> -->
	<!--弹层确定e -->
</body>
<script src="<%=basePath%>views/upai/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=basePath%>views/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=basePath%>views/js/layer.m.js"></script>
<script type="text/javascript" src="<%=basePath%>views/js/json2.js"></script>
<script type="text/javascript" src="<%=basePath%>views/js/sha1.js"></script>
<script type="text/javascript" src="<%=basePath%>views/js/CommonJS.js"></script>
<script type="text/javascript"
	src="<%=basePath%>views/js/WeiXin/WeChatJS-SDK.js"></script>
<script type="text/javascript"
	src="<%=basePath%>views/js/OrderCenter/OrderPayment.js"></script>
<script
	src="<%=basePath%>plugins/jQueryDistpicker/js/distpicker.data.js"></script>
<script src="<%=basePath%>plugins/jQueryDistpicker/js/distpicker.js"></script>
<script src="<%=basePath%>plugins/jQueryDistpicker/js/main.js"></script>
<script type="text/javascript">
	/* addressInit('cmbProvince', 'cmbCity', 'cmbArea'); */
	function pay() {
		if ($("#addressid").val() == "") {
			layer.open({
				title : '提示',
				content : "请选择地址"
			});
			return false;
		} else {
			var index = layer.open({
				type : 2,
				content : '请稍后...'
			});
			$
					.ajax({
						type : "post",
						url : "../mobile/createOrder",
						data : $("#dataform").serialize(),
						success : function(msg) {
							var info = eval('(' + msg + ')');
							if (info.error == "0000") {
								var orderid = info.orderid;
								$
										.ajax({
											url : "../mobile/payConfig",
											data : {
												ordertitle : orderid,
												total : info.paymoney
											},
											dataType : "json",
											success : function(jsapi) {
												// alert(JSON.stringify(jsapi)); 
												layer.close(index);
												if (jsapi.error == "1111") {
													layer
															.open({
																title : '提示',
																content : jsapi.information
															});
													return false;
												} else {
													WeixinJSBridge
															.invoke(
																	'getBrandWCPayRequest',
																	{
																		"appId" : jsapi.appId, // 公众号名称，由商户传入
																		"timeStamp" : jsapi.timeStamp, // 时间戳，自1970 年以来的秒数
																		"nonceStr" : jsapi.nonceStr, // 随机串
																		"package" : jsapi.package, // 预支付ID
																		"signType" : jsapi.signType, // 微信签名方式:
																		"paySign" : jsapi.paySign
																	// 微信签名
																	},
																	function(
																			res) {
																		if (res.err_msg == "get_brand_wcpay_request:ok") {
																			layer
																					.open({
																						title : '提示',
																						content : '支付成功'
																					});
																			location.href = "../mobile/home";
																		}
																	});
												}
											}
										});
							} else {
								layer.open({
									title : '提示',
									content : info.information
								});
								return false;
							}
						}
					})
		}
	}
</script>
</html>
